<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\modules\Product\models\ProductFlight */
/* @var $form yii\widgets\ActiveForm */
?>
<style type="text/css">
  .head-name{background-color: #337ab7;color: #FFF;padding: 10px 20px;margin-left: -15px;border-top-right-radius:6px;border-bottom-right-radius:6px; }
  .btn-default.addButton{background-color: #337ab7;color: #FFF;border-color:#337ab7;}
  .delButton{border: 1px solid #337ab7;color: #337ab7;}  
  .btn-default:hover{background-color: #337ab7;color: #FFF;}
  .table th{text-align: center;}
  .table td{text-align: center;}
</style>
<div class="product-extra">
    <?php $form = ActiveForm::begin(); ?>
    <div style="margin-bottom: 20px"><span class="head-name">机票</span></div>
    <input type="hidden" name="product_id" value="<?=$product->id?>">
    <table class="table table-striped table-bordered">
        <thead>
            <tr style="color: #337ab7;">
                <th class="col-md-3">名称</th>
                <th class="col-md-2">数量</th>
                <th class="col-md-2">价格</th>
                <th class="col-md-2">状态</th>
                <th class="col-md-2">备注</th>
                <th class="col-md-1">操作</th>
            </tr>
        </thead>
        <tbody>
             <tr class="form-box">
                <td class="col-md-3"><?= $form->field($filght, 'name[]')->textInput(['maxlength' => true,'data_key'=>0,'class'=>'form-control name'])->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($filght, 'num[]')->textInput()->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($filght, 'price[]')->textInput(['maxlength' => true])->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($filght, 'status[]')->dropdownList(\Yii::$app->params['status'])->label(false)?></td>
                <td class="col-md-2"><?= $form->field($filght, 'remark[]')->textarea(['rows'=>1])->label(false)?></td>
                <td class="col-md-1"><button type="button" class="btn btn-default addButton">添加</button></td>
             </tr>   
        </tbody>        
    </table>
    
    <hr>
    <div style="margin-bottom: 20px"><span class="head-name">地接酒店</span></div>
    <table class="table table-striped table-bordered">
        <thead>
            <tr style="color: #337ab7;">
                <th class="col-md-3">名称</th>
                <th class="col-md-2">数量</th>
                <th class="col-md-2">价格</th>
                <th class="col-md-2">状态</th>
                <th class="col-md-2">备注</th>
                <th class="col-md-1">操作</th>
            </tr>
        </thead>
        <tbody>
             <tr class="form-box">
                <td class="col-md-3"><?= $form->field($group, 'name[]')->textInput(['maxlength' => true,'data_key'=>0,'class'=>'form-control name'])->label(false)?></td>
                <td class="col-md-2"><?= $form->field($group, 'num[]')->textInput()->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($group, 'price[]')->textInput(['maxlength' => true])->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($group, 'status[]')->dropdownList(\Yii::$app->params['status'])->label(false)?></td>
                <td class="col-md-2"><?= $form->field($group, 'remark[]')->textarea(['rows'=>1])->label(false)?></td>
                <td class="col-md-1"><button type="button" class="btn btn-default addButton">添加</button></td>
             </tr>   
        </tbody>        
    </table>
    
    <hr> 
    <div style="margin-bottom: 20px"><span class="head-name">岸上游</span></div>
    <table class="table table-striped table-bordered">
        <thead>
            <tr style="color: #337ab7;">
                <th class="col-md-3">名称</th>
                <th class="col-md-2">数量</th>
                <th class="col-md-2">价格</th>
                <th class="col-md-2">状态</th>
                <th class="col-md-2">备注</th>
                <th class="col-md-1">操作</th>
            </tr>
        </thead>
        <tbody>
             <tr class="form-box">
                <td class="col-md-3"><?= $form->field($visit, 'name[]')->textInput(['maxlength' => true,'data_key'=>0,'class'=>'form-control name'])->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($visit, 'num[]')->textInput()->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($visit, 'price[]')->textInput(['maxlength' => true])->label(false)->label(false) ?></td>
                <td class="col-md-2"><?= $form->field($visit, 'status[]')->dropdownList(\Yii::$app->params['status'])->label(false)?></td>
                <td class="col-md-2"><?= $form->field($visit, 'remark[]')->textarea(['rows'=>1])->label(false)?></td>
                <td class="col-md-1"><button type="button" class="btn btn-default addButton">添加</button></td>
             </tr>   
        </tbody>        
    </table>
 

    <div class="form-group col-md-12 text-center">
        <?= Html::submitButton('创建',['class' =>'btn btn-success save']) ?>
    </div>

     <?php ActiveForm::end(); ?>

</div>


<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">
$(".addButton").click(function(){
     var formBox = $(this).parents(".form-box");
     var cloneDiv = formBox.clone(true); 
     var delButton = $('<button type="button" class="btn btn-default delButton">删除</button>');
     cloneDiv.find('input').val("");
     cloneDiv.find('textarea').val("");
     cloneDiv.find(".addButton").replaceWith(delButton);   
     cloneDiv.insertAfter(formBox);
     delButton.bind({
        click:function(){
            $(this).parents(".form-box").remove();
        },
     });
});  


</script>
<?php app\components\JsBlock::end() ?>
